import { ref, computed } from "vue";

export default function useFilterTodos(todos) {
  const filter = ref("all");
  const filter_todos = computed(() => {
    switch (filter.value) {
      case "done":
        return todos.value.filter((t) => t.completed);
      case "todo":
        return todos.value.filter((t) => !t.completed);
      default:
        return todos.value;
    }
  });

  return {
    filter,
    filter_todos,
  };
}
